import { createSlice } from '@reduxjs/toolkit';

const configureSlice = createSlice({
	name: 'configure',
	initialState: {
		hideUserInfo: false, // 是否隐藏用户信息
		hideChatBox: false, // 是否隐藏聊天
		hideBizPannel: false, // 是否隐藏业务操作
		hideLayoutMenu: false, // 是否隐藏布局菜单
		hideMultiLangMenu: false, // 是否隐藏多语言
		hideAgentManagementMenu: false, // 是否隐藏坐席管理菜单
		hideWatermark: false, // 是否隐藏水印
		hideTools: [], // 隐藏的工具栏button
	},

	reducers: {
		setConfigure(state, action) {
			const { hideUserInfo, hideChatBox, hideBizPannel, hideLayoutMenu, hideMultiLangMenu, hideTools, ticket, hideAgentManagementMenu, serviceRecord, hideWatermark } = action.payload;
			let cloneState: any = { ...state };
			cloneState.hideUserInfo = !!hideUserInfo;
			cloneState.hideChatBox = !!hideChatBox;
			cloneState.hideBizPannel = !!hideBizPannel;
			cloneState.hideLayoutMenu = !!hideLayoutMenu;
			cloneState.hideMultiLangMenu = !!hideMultiLangMenu;
			cloneState.hideAgentManagementMenu = !!hideAgentManagementMenu;
			cloneState.hideWatermark = !!hideWatermark;
			cloneState.hideTools = hideTools ? [...hideTools] : [];
			return cloneState;
		},
		clearConfigureData() {
			return {
				hideUserInfo: false,
				hideChatBox: false,
				hideBizPannel: false,
				hideLayoutMenu: false,
				hideMultiLangMenu: false,
				hideAgentManagementMenu: false,
				hideWatermark: false,
				hideTools: [],
			};
		}
	}
});

export const { setConfigure, clearConfigureData } = configureSlice.actions;
export default configureSlice.reducer;
